﻿
using System.Text.RegularExpressions;

namespace Devices.Print
{
    public static class Extend
    {
        public static double? GetNum(this string str)
        {
            if (string.IsNullOrEmpty(str))
                return null;
            string newstr = Regex.Replace(str, @"[^\d.\d]", "");
            if (string.IsNullOrEmpty(newstr))
                return null;
            double num = 0;
            if (double.TryParse(newstr, out num))
                return num;
            else
                return null;
        }
    }
}
